// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.AspNetCore.Mvc;
using OpenTelemetry.Proto.Collector.Logs.V1;

namespace iPanel.Otlp.Grpc;

[Authorize(Policy = OtlpAuthorization.PolicyName)]
[SkipStatusCodePages]
public class OtlpGrpcConsoleLogService : ConsoleLogService.ConsoleLogServiceBase
{
    private readonly OtlpConsoleLogService otlpConsoleLogService;

    public OtlpGrpcConsoleLogService(OtlpConsoleLogService otlpConsoleLogService)
    {
        this.otlpConsoleLogService = otlpConsoleLogService;
    }

    public override Task<ExportResponse> Export(ExportRequest request, ServerCallContext context)
    {
        otlpConsoleLogService.Export(request);
        return Task.FromResult(new ExportResponse { Output = 1 });
    }
}
